import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/src/backdrop.dart';
import 'package:get/get.dart';

class UiBackdropScafflod extends StatelessWidget {
  const UiBackdropScafflod({
    super.key,
    this.body,
    this.backgroundColor,
    this.headerColor,
    this.bodyBuider,
    this.appBar,
    this.showBottomBorder = false,
    this.bottomBorderColor,
  });
  final Widget? body;
  final Color? backgroundColor;
  final Color? headerColor;
  final Function(double top, double bottom)? bodyBuider;
  final PreferredSizeWidget? appBar;
  final bool showBottomBorder;
  final Color? bottomBorderColor;
  @override
  Widget build(BuildContext context) {
    double top = MediaQuery.of(Get.context!).viewPadding.top +
        (Get.theme.appBarTheme.toolbarHeight ?? kToolbarHeight);
    double bottom = kBottomNavigationBarHeight +
        MediaQuery.of(Get.context!).viewPadding.bottom;
    return Scaffold(
      appBar: appBar,
      backgroundColor: backgroundColor,
      body: Stack(
        children: [
          Positioned.fill(
            child: Builder(builder: (context) {
              return bodyBuider?.call(top, bottom) ?? (body ?? Container());
            }),
          ),
          Align(
            alignment: Alignment.topCenter,
            child: Column(
              children: [
                UiBackdrop(
                  enable: false,
                  child: Container(
                    height: top,
                    color: (headerColor ?? backgroundColor)?.withOpacity(1),
                  ),
                ),
                if (showBottomBorder)
                  Divider(
                    height: 0,
                    color: bottomBorderColor,
                  ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
